<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<!-- HTML file produced from file: manual.tex --
 -- using Hyperlatex v 2.3.1 (c) Otfried Cheong--
 -- on Emacs 21.4 (patch 12) "Portable Code" XEmacs Lucid, Wed Jun  2 18:56:56 2004 -->
<HEAD>
<TITLE>Scheme 48 Manual -- Command processor support</TITLE>

</HEAD><BODY BGCOLOR="#ffffff">
<EM>Scheme 48 Manual</EM> | <A HREF="s48manual.html#top_node">Contents</A> | In Chapter: <A HREF="s48manual_24.html">Module system</A><BR>Previous: <A HREF="s48manual_31.html">Semantics of configuration mutation</A> | Next: <A HREF="s48manual_33.html">Configuration packages</A>
<H2>Command processor support</H2>

<P>While it is possible to use the Scheme&nbsp;48 static linker for program
development, it is far more convenient to use the development
environment, which supports rapid turnaround for program changes.  The
programmer interacts with the development environment through a <EM>command processor</EM>.  The command processor is like the usual Lisp
read-eval-print loop in that it accepts Scheme forms to evaluate.
However, all meta-level operations, such as exiting the Scheme system
or requests for trace output, are handled by <EM>commands,</EM> which are
lexically distinguished from Scheme forms.  This arrangement is
borrowed from the Symbolics Lisp Machine system, and is reminiscent of
non-Lisp debuggers.  Commands are a little easier to type than Scheme
forms (no parentheses, so you don't have to shift), but more
importantly, making them distinct from Scheme forms ensures that
programs' namespaces aren't cluttered with inappropriate bindings.
Equivalently, the command set is available for use regardless of what
bindings happen to be visible in the current program.  This is
especially important in conjunction with the module system, which puts
strict controls on visibility of bindings.
<P>The Scheme&nbsp;48 command processor supports the module system with a
variety of special commands.  For commands that require structure
names, these names are resolved in a designated configuration package
that is distinct from the current package for evaluating Scheme forms
given to the command processor.  The command processor interprets
Scheme forms in a particular current package, and there are commands
that move the command processor between different packages.
<P>Commands are introduced by a comma (<TT>,</TT>) and end at the end of
line.  The command processor's prompt consists of the name of the
current package followed by a greater-than (<TT>&gt;</TT>).
<P><DL><DT><B></B><DD><CODE>,open <CODE><I>structure</I></CODE><I><sup>*</sup></I></CODE> <BR>The <TT>,open</TT> command opens new structures in the current
    package, as if the package's definition's <TT>open</TT> clause
    had listed <CODE><I>structure</I></CODE>.
    As with <TT>open</TT> clauses the visible names can be modified,
    as in
<BLOCKQUOTE><PRE>
,open (subset foo (bar baz))
</PRE></BLOCKQUOTE>
which only makes the <CODE>bar</CODE> and <CODE>baz</CODE> bindings from
    structure <CODE>foo</CODE> visible.
<P><DT><B></B><DD><CODE>,config</CODE> <BR>The <TT>,config</TT> command sets the command processor's current
    package to be the current configuration package.  Forms entered at
    this point are interpreted as being configuration language forms,
    not Scheme forms.
<P><DT><B></B><DD><CODE>,config <CODE><I>command</I></CODE></CODE> <BR>This form of the <TT>,config</TT> command executes another command in
    the current configuration package.  For example,
<BLOCKQUOTE><PRE>
,config ,load foo.scm
</PRE></BLOCKQUOTE>
interprets configuration language forms from the file <TT>foo.scm</TT> in the current configuration package.
<P><DT><B></B><DD><CODE>,config-package-is <CODE><I>struct-name</I></CODE></CODE> <BR>The <TT>,config-package-is</TT> command designates a new configuration
    package for use by the <TT>,config</TT> command and resolution of
    <CODE><I>struct-name</I></CODE>s for other commands such as <TT>,in</TT> and
    <TT>,open</TT>.  See
    <A HREF="s48manual_33.html">below</A>
    for information on making new configuration packages.
<P><DT><B></B><DD><CODE>,in <CODE><I>struct-name</I></CODE></CODE> <BR>The <TT>,in</TT> command moves the command processor to a specified
    structure's underlying package.  For example:
<BLOCKQUOTE><PRE>
user&gt; ,config
config&gt; (define-structure foo (export a)
          (open scheme))
config&gt; ,in foo
foo&gt; (define a 13)
foo&gt; a
13
</PRE></BLOCKQUOTE>
In this example the command processor starts in a package called
    <TT>user</TT>, but the <TT>,config</TT> command moves it into the
    configuration package, which has the name <TT>config</TT>.  The <TT>define-structure</TT> form binds, in <TT>config</TT>, the name <TT>foo</TT> to
    a structure that exports <TT>a</TT>.  Finally, the command <TT>,in
    foo</TT> moves the command processor into structure <TT>foo</TT>'s
    underlying package.
<P>    A package's body isn't executed (evaluated) until the package is
    <EM>loaded</EM>, which is accomplished by the <TT>,load-package</TT>
    command.
<P><DT><B></B><DD><CODE>,in <CODE><I>struct-name</I></CODE> <CODE><I>command</I></CODE></CODE> <BR>This form of the <TT>,in</TT> command executes a single command in the
    specified package without moving the command processor into that
    package.  Example:
<BLOCKQUOTE><PRE>
,in mumble (cons 1 2)
,in mumble ,trace foo
</PRE></BLOCKQUOTE>
<P><DT><B></B><DD><CODE>,user [<CODE><I>command</I></CODE>]</CODE> <BR>This is similar to the <TT>,config</TT> and <TT>,in</TT> commands.  It
    moves to or executes a command in the user package (which is the
    default package when the Scheme&nbsp;48 command processor starts).
<P><DT><B></B><DD><CODE>,user-package-is <CODE><I>name</I></CODE></CODE> <BR>The <TT>,user-package-is</TT> command designates a new user
    package for use by the <TT>,user</TT> command.
<P><DT><B></B><DD><CODE>,load-package <CODE><I>struct-name</I></CODE></CODE> <BR>The <TT>,load-package</TT> command ensures that the specified structure's
    underlying package's program has been loaded.  This 
    consists of (1) recursively ensuring that the packages of any
    opened or accessed structures are loaded, followed by (2)
    executing the package's body as specified by its definition's <TT>begin</TT> and <TT>files</TT> forms.
<DT><B></B><DD><CODE>,reload-package <CODE><I>struct-name</I></CODE></CODE> <BR>This command re-executes the structure's package's program.  It
    is most useful if the program comes from a file or files, when
    it will update the package's bindings after mutations to its
    source file.
<P><DT><B></B><DD><CODE>,load <CODE><I>filespec</I></CODE> ...</CODE> <BR>The <TT>,load</TT> command executes forms from the specified file or
    files in the current package.  <TT>,load <CODE><I>filespec</I></CODE></TT> is similar
    to <TT>(load "<CODE><I>filespec</I></CODE>")</TT>
    except that the name <TT>load</TT> needn't be bound in the current
    package to Scheme's <TT>load</TT> procedure.
<P><DT><B></B><DD><CODE>,for-syntax [<CODE><I>command</I></CODE>]</CODE> <BR>This is similar to the <TT>,config</TT> and <TT>,in</TT> commands.  It
    moves to or executes a command in the current package's "package
    for syntax," which is the package in which the forms <I>f</I> in
    <TT>(define-syntax <CODE><I>name</I></CODE> <CODE><I>f</I></CODE>)</TT> are evaluated.
<P><DT><B></B><DD><CODE>,new-package</CODE> <BR>The <TT>,new-package</TT> command creates a new package, in which only
    the standard Scheme bindings are visible, and moves the command
    processor to it.
<P><DT><B></B><DD><CODE>,structure <CODE><I>name</I></CODE> <CODE><I>interface</I></CODE></CODE> <BR>The <TT>,structure</TT> command defines <CODE><I>name</I></CODE> in the
    configuration package to be a structure with interface
    <CODE><I>interface</I></CODE> based on the current package.
<P></DL>
<P><P><P>
  
Previous: <A HREF="s48manual_31.html">Semantics of configuration mutation</A> | Next: <A HREF="s48manual_33.html">Configuration packages</A></BODY></HTML>
